<?php
include_once('constants.php');

$morningafternoon = $_POST['morningafternoon'];
$rundate = $_POST['rundate'];
$fileType = $_POST['padpds'];
//$morningafternoon = $_GET['morningafternoon'];
//$rundate = $_GET['rundate'];
//$fileType = $_GET['filetype'];
$fileName = '';


if(!isset($morningafternoon)||$morningafternoon=='0')
{echo "Sorry, you are in the wrong page";
exit();
}



$fileName .= ACH_FILES.'/'.$fileType.$rundate.$morningafternoon.'.txt';
echo $fileName.'<br/>';
if (file_exists($fileName)){
	header('Content-Description: File Transfer');
	header('Content-Type: text/plain');
	header('Content-Disposition: attachment; filename="'.basename($fileName).'"');
	header('Content-Transfer-Encoding: binary');
	header('Connection: Keep-Alive');
	header('Expires: 0');
	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	header('Pragma: public');
	header('Content-Length: ' . filesize($fileName));
	readfile($fileName);
}
else {
	echo "Target file does not exist";
}
?>